package ray.mgocc.title;

public class WaterBear extends WeekTitle{
    public String getName(){ return "WATER BEAR";}
    public int getPriority(){ return 12;}
    public int getPlayTimeThreshold(){ return 5;}
    public void init(){
        super.init();
        addRequirementSet("Stealth Deathmatch");
        addRequirementSet("Rescue Mission");
        addRequirementSet("Team Sneaking");
    }
    private void addRequirementSet(String rule){
        add(new DeathRequirement(rule));
        add(new RoundRequirement(50,"Stealth Deathmatch"));
    }
    class DeathRequirement extends Requirement{
        private String rule;
        DeathRequirement(String rule){
            this.rule = rule;
        }
        public String getName(){ return "death("+this.rule+")"; }
        public double getDeathRatio(){
            double ratio;
            final String KEY = this.rule +".";
            int round = getValue(KEY+"ROUND");
            int deaths = getValue(KEY+"ALL.DEATHS");
            if(0==round){
                ratio = 0;
            }else{
                ratio = ((double)deaths)/round;
            }
            return ratio;
        }
        private double getThreshold(){
            return 0.5;
        }
        public double getRatio(){
            double ratio;
            double value = getDeathRatio();
            if(0==value){
                ratio = 0;
            }else{
                ratio = getThreshold()/value;
            }
            return ratio;
        }
        public String toString(){
            return super.toString()+"("+getThreshold()+">"+format(getDeathRatio())+")";
        }
    }
}

